package com.xbdun.web.bmp.controller.system;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.dubbo.config.annotation.Reference;
import com.xbdun.common.api.XbdUnStringResult;
import com.xbdun.common.constant.XbdunLoginConst;
import com.xbdun.comweb.bmp.frame.annotation.XbdunLogin;
import com.xbdun.comweb.bmp.util.UserInfoUtil;
import com.xbdun.facade.bmp.constant.DubboBmpConst;
import com.xbdun.facade.bmp.request.system.RolePagerRequest;
import com.xbdun.facade.bmp.request.system.RoleRequest;
import com.xbdun.facade.bmp.result.system.RolePagerResult;
import com.xbdun.facade.bmp.service.system.RoleFacade;

import lombok.extern.slf4j.Slf4j;

/**
* 角色管理
* @ClassName: S100101101Controller
* @Description: 角色管理
* @author wwq
* @date 2017年5月11日13:20:50
*/
@Controller
@Slf4j
@XbdunLogin({XbdunLoginConst.XBDADMINT,XbdunLoginConst.ADMINS})
public class S100101101Controller extends BaseSystemController{
	@Reference(registry=DubboBmpConst.REGISTRYS)
	RoleFacade roleFacade;
	
	/**
	 * 机构角色管理
	 * @return
	 */
	@RequestMapping("100101101")
    public String index(){
        return ROOT_PATH+"100101101";
    }
	/**
	 * 机构角色列表
	 */
	@RequestMapping("100101101103")
	@ResponseBody
	public RolePagerResult queryPager(RolePagerRequest request){
		RolePagerResult result = new RolePagerResult();
		try{
			log.info("检索机构角色传入参数{}",request);
			result = roleFacade.queryPager(request, UserInfoUtil.getClient(getRequest()));
		}catch(Exception e){
			result.setBizException(e);
			log.error("检索机构角色异常,{}", e);
		}
		return result;
	}
	
	/***
	 * 新增机构角色
	 */
	@RequestMapping("100101101100")
	@ResponseBody
	public XbdUnStringResult addOrgUser(RoleRequest request){
		XbdUnStringResult result = new XbdUnStringResult();
		try{
			log.info("新增机构角色传入参数,{}", request);
			result = roleFacade.addRole(request, UserInfoUtil.getClient(getRequest()));
		}catch(Exception e){
			result.setBizException(e);
			log.error("新增机构角色异常,{}", e);
		}
		return result;
	}
	
	/***
	 * 修改机构角色
	 */
	@RequestMapping("100101101101")
	@ResponseBody
	public XbdUnStringResult modifyRole(RoleRequest request){
		XbdUnStringResult result = new XbdUnStringResult();
		try{
			log.info("修改机构角色传入参数,{}", request);
			result = roleFacade.modifyRole(request, UserInfoUtil.getClient(getRequest()));
		}catch(Exception e){
			result.setBizException(e);
			log.error("修改机构角色异常,{}", e);
		}
		return result;
	}
	
	/***
	 * 删除机构角色
	 */
	@RequestMapping("100101101102")
	@ResponseBody
	public XbdUnStringResult deleteRole(Long id){
		XbdUnStringResult result = new XbdUnStringResult();
		try{
			log.info("修改机构角色传入参数,{}", id);
			result = roleFacade.deleteRole(id, UserInfoUtil.getClient(getRequest()));
		}catch(Exception e){
			result.setBizException(e);
			log.error("修改机构角色异常,{}", e);
		}
		return result;
	}
	
	
	
	
}
